package demo03Static;

/**
 * @author mubei
 * @date 2021/11/20
 * @description
 */
public class StaticProxy {

    public static void main(String[] args) {
        WeddingCompany company = new WeddingCompany(new You());
        company.HappyMarry();

        new WeddingCompany(new You()).HappyMarry();
        new Thread(() -> System.out.println("爱你呦")).start();
    }
}

interface Marry {
    void HappyMarry();
}

// 真实角色
class You implements Marry {

    @Override
    public void HappyMarry() {
        System.out.println("结婚了 可以的");
    }
}

// 代理
class WeddingCompany implements Marry {

    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }


    @Override
    public void HappyMarry() {
        System.out.println("结婚之前");
        this.target.HappyMarry();
        System.out.println("结婚之后");
    }
}